<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>新闻列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/news.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>

	<body>
		<!--header-->
		<div id="header">
			<h1>新闻</h1>
			<span class="backicon"></span>
		</div>
		<!--content-->
		<div class="body">
			<ul class="news" id="news">
				<li v-for="(news,index) in newsList" @tap="jumpNewsDetail(index)" v-if="newsList!=''">
					<a href="javascript:;">
						<div class="news_txt_left">
							<span class="ellipsis">{{news.title}}</span>
							<p class="ellipsis" v-text="repalceHtml(news.content)">  
								</p>
							<span class="visitors"><em>{{news.view}}</em>次浏览</span>
						</div>
						<div class="news_img_right">
							<img :src="htp+news.thumb_pic">
						</div>
					</a>
				</li>  

			</ul>
		</div>
		<script>
			new Vue({
				el:"#news",
				data:{
					newsList:"",
					htp:"",
					ticket:"",
				    sign:""
				},
				methods:{
					jumpNewsDetail:function(nIndex){
						var nId=this.newsList[nIndex].id;
						mui.plusReady(function(){
							//openurl("new_details")
							mui.openWindow({
								url:"new_details.html",//打开详情页
								extras:{
									name:nId//页面传值
								},
								waiting:{
	                                autoShow:false//自动显示等待框，默认为true
	                            }
							})
						})
					}
				}, 
				created:function(){
					this.ticket=localStorage.getItem("tick")
                    this.sign=localStorage.getItem("sig")
					//获取新闻列表
					this.htp=domain2
					this.$http.post(domain+"/news/getList?t="+this.ticket+"&sign="+this.sign,{
			        	page_size:10
			        },{emulateJSON:true}).then(//获取新闻列表
			            function (res) {
			                // 处理成功的结果
			                if(res.body.code==1){
			                  console.log(res.body)	
			                  this.newsList=res.body.data.list;
			                } 
			            },function (res) {
			            // 处理失败的结果
			            console.log(res)   
			            }
			        );
				}
			})
		</script>
	</body>

</html>